package org.hhchat.others.toutiao.p2018;

import java.util.*;

/**
 * Created this one by huminghao on 2018/4/15.
 */
public class MyMain01 {
    public static void main(String[] args) {
        int n;
        List<List<Long>> inputList = new ArrayList<>();
        List<TreeSet<Integer>> disList = new ArrayList<>();
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        while (n-- > 0) {
            int count = scanner.nextInt();
            List<Long> inputOne = new ArrayList<>();
            while (count-- > 0) {
                Long cur = scanner.nextLong();
                inputOne.add(cur);
            }
            inputList.add(inputOne);
            disList.add(getDis(inputOne));
        }

        for (int i = 0; i < inputList.size(); i++) {
            List<Long> input = inputList.get(i);
            // 获取首尾距离
            Long last = input.get(input.size()-1);
            TreeSet<Integer> dis = disList.get(i);
            if (input.size() < 2) {
                System.out.println(0);
            }
            for (int d : dis) {
                if (check(input, d, last)) {
                    System.out.println(d);
                    break;
                }
            }
        }
    }

    public static TreeSet<Integer> getDis(List<Long> list) {
        TreeSet<Integer> set = new TreeSet<>();
        for (int i = 0; i < list.size()-1; i++) {
            for (int j = i + 1; j < list.size(); j++) {
                set.add((int)(list.get(j) - list.get(i)));
            }
        }
        return set;
    }


    public static boolean check(List<Long> set, long d, Long last) {
        for (Long it : set) {
            if (it + d > last) {
                return true;
            }
            if (it + d <= last && !set.contains(it + d)) {
                return false;
            }
        }
        return true;
    }

}
